//
//  StudyVC.m
//  doubleEduStudents
//
//  Created by 盛洋 on 2021/3/29.
//  Copyright © 2021 shengYang. All rights reserved.
//

#import "StudyVC.h"
#import "StudyLeftView.h"
#import "StudyRightView.h"
#import "StudyRightView.h"
#import "SearchVC.h"

@interface StudyVC ()
@property(strong,nonatomic)UIScrollView *scrollview;
@end

@implementation StudyVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"学习中心";
    [self.backKuang setHidden:YES];
    [self createNavigationBarRightBarButtonItemWithTitle:@"" font:16 image:@"home_search" target:self action:@selector(search)];
    [self setUI];
}

-(void)setUI{
    self.scrollview=[[UIScrollView alloc] initWithFrame:CGRectMake(SCREEN_W*0.1, SCREEN_H*0.125, SCREEN_W*0.9, SCREEN_H*0.75)];
    self.scrollview.backgroundColor = [UIColor clearColor];
    [_scrollview setShowsHorizontalScrollIndicator:NO];
    [_scrollview setShowsVerticalScrollIndicator:NO];
    _scrollview.tag=999;
    _scrollview.delegate=self;
    _scrollview.contentSize=CGSizeMake(self.scrollview.frame.size.width*2, 0);
    [_scrollview setPagingEnabled:YES];
    [self.view addSubview:_scrollview];
    for (int i = 0; i<2; i++) {
        if (i == 0) {
            UICollectionViewFlowLayout *layout1 = [[UICollectionViewFlowLayout alloc]init];
            layout1.scrollDirection = UICollectionViewScrollDirectionVertical;
            StudyLeftView *left_view = [[StudyLeftView alloc]initWithFrame:self.backKuang.frame collectionViewLayout:layout1];
            left_view.frame = CGRectMake(i*self.scrollview.frame.size.width, 0, self.scrollview.frame.size.width, self.scrollview.frame.size.height);
            left_view.VC = self;
            [left_view addView];
            [_scrollview addSubview:left_view];
        }else{
            UICollectionViewFlowLayout *layout2 = [[UICollectionViewFlowLayout alloc]init];
            layout2.scrollDirection = UICollectionViewScrollDirectionHorizontal;
            StudyRightView *right_view = [[StudyRightView alloc]initWithFrame:self.backKuang.frame collectionViewLayout:layout2];
            right_view.frame = CGRectMake(i*self.scrollview.frame.size.width, 0, self.scrollview.frame.size.width, self.scrollview.frame.size.height);
            right_view.VC = self;
            [right_view addView];
            [_scrollview addSubview:right_view];
        }
    }
}

/**
 * 搜索
 */
-(void)search{
    SearchVC *vc = [[SearchVC alloc]init];
    [self PushToViewController:vc];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
